﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NHibernate.Criterion;
using Longtop.Web.SaleWeb.Home;
using Discuz.Toolkit;
using Longtop.Web.SaleWeb.Admin.Helper;
using Longtop.Web.WebSite.Shared;
using Discuz.Entity;
using NHibernate.Linq;
using Longtop.Web.SaleWeb.Models;
using Longtop.Web.WebSite.Models;
namespace Longtop.Web.SaleWeb.Controllers {
    public class HomeController : ControllerBase {
        public ActionResult Index() {

            //ds.Login(DntUid, model.Password, false, 100, "");

            var model = new IndexModel() {
                ScrollTopics = Discuz.Data.Topics.GetTopicList(12, 10, 1, 0, "")
             ,
                FaqTopics = Discuz.Data.Topics.GetTopicListByCondition(10, 1, 0, " and fid in(27) ", "postdatetime", 1)
             ,
                KnowledgeTopics = Discuz.Data.Topics.GetTopicListByCondition(10, 1, 0, " and fid in(6,7,8,9,10) ", "postdatetime", 1)
                ,
                LifeTopics = Discuz.Data.Topics.GetTopicListByCondition(10, 1, 0, " and fid in(21,22,23,24,25) ", "postdatetime", 1)
             ,
                NoticeTopics = Discuz.Data.Topics.GetTopicListByCondition(10, 1, 0, " and fid in(2,3,4) ", "postdatetime", 1)
           ,
                WorkflowTopics = Discuz.Data.Topics.GetTopicListByCondition(10, 1, 0, " and fid in(3) ", "postdatetime", 1)
            ,
                ReportTopics = Discuz.Data.Topics.GetTopicListByCondition(10, 1, 0, " and fid in(13) ", "postdatetime", 1)
            };
            model.Sales = Sale.GetAllSales()
               .OrderByDescending(s => s.GetMonthAchieve(null))
               .Take(10).ToList();

            model.StarSales = Sale.GetAllSales()
               .OrderByDescending(s => s.GetMonthAchieve(null))
               .Take(2).ToList();

            return View(model);
        }

        public ActionResult NextPublish() {
            return PartialView(new SiteMasterModel());
        }
    }
}
